Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
ripple-address-codec
Advanced tools
The ripple-address-codec npm package provides utilities for encoding and decoding Ripple (XRP) addresses. It is useful for developers working with the Ripple network who need to handle address validation, encoding, and decoding.
Encoding a Ripple Address
This feature allows you to encode a Ripple account ID into a standard Ripple address format. The `encodeAccountID` function takes a Buffer containing the account ID and returns the encoded address.
const { encodeAccountID } = require('ripple-address-codec');
const accountID = Buffer.from('rippleAccountID', 'hex');
const encodedAddress = encodeAccountID(accountID);
console.log(encodedAddress);
Decoding a Ripple Address
This feature allows you to decode a Ripple address back into its original account ID. The `decodeAccountID` function takes a Ripple address string and returns a Buffer containing the decoded account ID.
const { decodeAccountID } = require('ripple-address-codec');
const rippleAddress = 'rippleAddressString';
const decodedAccountID = decodeAccountID(rippleAddress);
console.log(decodedAccountID.toString('hex'));
Validating a Ripple Address
This feature allows you to validate whether a given string is a valid Ripple address. The `isValidClassicAddress` function takes a Ripple address string and returns a boolean indicating its validity.
const { isValidClassicAddress } = require('ripple-address-codec');
const rippleAddress = 'rippleAddressString';
const isValid = isValidClassicAddress(rippleAddress);
console.log(isValid);
The ripple-lib package is a comprehensive library for interacting with the Ripple network. It includes functionalities for address encoding/decoding, transaction signing, and network communication. Compared to ripple-address-codec, ripple-lib offers a broader range of features beyond just address handling.
The xrpl package is another library for interacting with the XRP Ledger. It provides tools for address encoding/decoding, transaction management, and ledger querying. Similar to ripple-lib, xrpl offers a more extensive set of functionalities compared to ripple-address-codec.
> var api = require('ripple-address-codec');
> api.decodeSeed('sEdTM1uX8pu2do5XvTnutH6HsouMaM2')
{ version: [ 1, 225, 75 ],
bytes: [ 76, 58, 29, 33, 63, 189, 251, 20, 199, 194, 141, 96, 148, 105, 179, 65 ],
type: 'ed25519' }
> api.decodeSeed('sn259rEFXrQrWyx3Q7XneWcwV6dfL')
{ version: 33,
bytes: [ 207, 45, 227, 120, 251, 221, 126, 46, 232, 125, 72, 109, 251, 90, 123, 255 ],
type: 'secp256k1' }
> api.decodeAccountID('rJrRMgiRgrU6hDF4pgu5DXQdWyPbY35ErN')
[ 186,
142,
120,
98,
110,
228,
44,
65,
180,
109,
70,
195,
4,
141,
243,
161,
195,
200,
112,
114 ]
We give you the kitchen sink.
> console.log(api)
{ Codec: [Function: AddressCodec],
codecs:
{ bitcoin:
{ alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz',
codec: [Object],
base: 58 },
ripple:
{ alphabet: 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz',
codec: [Object],
base: 58 },
tipple:
{ alphabet: 'RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz',
codec: [Object],
base: 58 },
stellar:
{ alphabet: 'gsphnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCr65jkm8oFqi1tuvAxyz',
codec: [Object],
base: 58 } },
decode: [Function: decode],
encode: [Function: encode],
decodeEdSeed: [Function],
encodeEdSeed: [Function],
isValidEdSeed: [Function],
decodeSeed: [Function],
encodeSeed: [Function],
isValidSeed: [Function],
decodeAccountID: [Function],
encodeAccountID: [Function],
isValidAccountID: [Function],
decodeAddress: [Function],
encodeAddress: [Function],
isValidAddress: [Function],
decodeNodePublic: [Function],
encodeNodePublic: [Function],
isValidNodePublic: [Function],
decodeNodePrivate: [Function],
encodeNodePrivate: [Function],
isValidNodePrivate: [Function],
decodeK256Seed: [Function],
encodeK256Seed: [Function],
isValidK256Seed: [Function] }
var pubVersion = [0x04, 0x88, 0xB2, 0x1E];
var options = {version: pubVersion, alphabet: 'bitcoin'};
var key = 'xpub661MyMwAqRbcEYS8w7XLSVeEsBXy79zSzH1J8vCdxAZningWLdN3zgtU6LBpB85b3D2yc8sfvZU521AAwdZafEz7mnzBBsz4wKY5e4cp9LB';
var decoded = api.decode(key, options);
var reencoded = api.encode(decoded, options);
console.log(key);
// 'xpub661MyMwAqRbcEYS8w7XLSVeEsBXy79zSzH1J8vCdxAZningWLdN3zgtU6LBpB85b3D2yc8sfvZU521AAwdZafEz7mnzBBsz4wKY5e4cp9LB'
console.log(reencoded);
// 'xpub661MyMwAqRbcEYS8w7XLSVeEsBXy79zSzH1J8vCdxAZningWLdN3zgtU6LBpB85b3D2yc8sfvZU521AAwdZafEz7mnzBBsz4wKY5e4cp9LB'
FAQs
encodes/decodes base58 encoded XRP Ledger identifiers
We found that ripple-address-codec demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.